package com.itstyle.webhook.aspect;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * @author : 765819328@qq.com
 * @version :
 * @date : Created in 2021/8/18 17:28
 * @description:
 * @modified By:
 */
@Aspect
@Component
public class SendAOP {
    @Before("execution(* com.itstyle.webhook.Application.webhook(..))")
    public void before() {
        RequestAttributes ra = RequestContextHolder.getRequestAttributes();
        ServletRequestAttributes sra = (ServletRequestAttributes) ra;
        HttpServletRequest request = sra.getRequest();  //获取request 可以从中获取参数或cookie
        System.out.println("我是切面");
    }
}
